 // 用户id
 let uid = localStorage.getItem("id");
 // 6-1 购物车列表
 function loadCartList() {
   let cartListAPI = "http://jx.xuzhixiang.top/ap/api/cart-list.php";
   axios.get(cartListAPI, { params: { id: uid } }).then((r) => {
     console.log(r.data);
     let cartArr = r.data.data;
     console.log(cartArr);
     //   循环遍历
     //   map 对象数组 映射为 字符串数组
     let liArr = cartArr.map(
       (v) => `
         <li>
         <img src="${pObj.pimg}" alt="">
             <p>${v.pprice}</p>
             <input min="1" onchange="pnumChange(${v.pid},this)" type="number" name="" id=""  value="${v.pnum}"/>
             <button onclick="delBtnClick(${v.pid},this)">删除</button>
         </li>
       `
     );
     console.log(liArr);
     //多个li标签链接成一个字符串 给 ul
     document.querySelector("#clist").innerHTML = liArr.join("");
   });
 }

 loadCartList();

 //   删除
 function delBtnClick(pid, btn) {
   console.log(pid, btn);

   let url = "http://jx.xuzhixiang.top/ap/api/cart-delete.php";
   axios.get(url, { params: { uid, pid } }).then((r) => {
     console.log(r.data);
     //   删除成功
     btn.parentNode.remove();
   });
 }

 //   修改
 function pnumChange(pid, ipt) {
   console.log(pid, ipt);
   //内容改变事件
   let pnum = ipt.value;
   console.log(pnum);
   let url = "http://jx.xuzhixiang.top/ap/api/cart-update-num.php";
   axios
     .get(url, {
       params: {
         pnum,
         uid,
         pid,
       },
     })
     .then((r) => {
       //修改成功
       console.log(r.data);
     });
 }